<template>






    <div>

        <div class="default-main">
            <div class="small-panel-box">
                <p style="margin-bottom: 10px">
                    <el-divider content-position="left"><el-text class="mx-1" size="large">平台收益</el-text></el-divider>


                </p>
                <div style="display:flex;margin-bottom: 15px" >
                    <div  style="width:300px">
                        <el-date-picker
                            v-model="daterange"
                            type="daterange"
                            :shortcuts="shortcuts"
                            range-separator="To"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            value-format="YYYY-MM-DD"
                        />
                    </div>
                    <div style="margin-left: 70px">
                        <el-button type="primary"  @click="data_board">查询</el-button>
                    </div>

                </div>
                <el-row :gutter="20">
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel user-reg suspension" >
                            <div class="small-panel-title">平台抽佣金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#F48595" size="20" name="fa fa-cny" />
                                    <span id="user_reg_number">{{data?.commission_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(1)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>

                    <el-col :sm="12" :lg="6">
                        <div class="small-panel users suspension">
                            <div class="small-panel-title">平台发放金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#F48595" size="20" name="fa fa-cny" />
                                    <span id="users_number">{{data?.send_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(2)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel addons suspension" >
                            <div class="small-panel-title">平台收益金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#F48595" size="20" name="fa fa-cny" />
                                    <span id="addons_number">{{data?.commission_earnings}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(3)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>

                </el-row>
            </div>
            <div class="small-panel-box"  style="margin-top: -5px" >

                <p style="margin-bottom: 10px">
                    <el-divider content-position="left"><el-text class="mx-1" size="large">待返数据</el-text></el-divider>
                </p>
                <el-row :gutter="20">
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel users suspension" >
                            <div class="small-panel-title">返购池金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#BE89FF" size="20" name="fa fa-cny" />
                                    <span id="users_number">{{data?.real_back_total}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(4)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel user-reg suspension">
                            <div class="small-panel-title">持币池金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#BE89FF" size="20" name="fa fa-cny" />
                                    <span id="user_reg_number">{{data?.coin_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(5)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>

                    <el-col :sm="12" :lg="6">
                        <div class="small-panel users suspension">
                            <div class="small-panel-title">十级池</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#BE89FF" size="20" name="fa fa-cny" />
                                    <span id="users_number">{{data?.push_send_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(6)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel addons suspension" >
                            <div class="small-panel-title">商家十级池</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#BE89FF" size="20" name="fa fa-cny" />
                                    <span id="addons_number">{{data?.shop_push_send_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(7)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel addons suspension" >
                            <div class="small-panel-title">股东池</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#BE89FF" size="20" name="fa fa-cny" />
                                    <span id="addons_number">{{data?.shareholder_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(17)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel addons suspension" >
                            <div class="small-panel-title">十人池</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#BE89FF" size="20" name="fa fa-cny" />
                                    <span id="addons_number">{{data?.ten_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(18)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel addons suspension" >
                            <div class="small-panel-title">百人池</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#BE89FF" size="20" name="fa fa-cny" />
                                    <span id="addons_number">{{data?.hundred_money}}</span>
                                </div>
                                <div class="content-right"  @click="platform_revenue_action(19)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>

                </el-row>
            </div>
            <div class="small-panel-box"  style="margin-top: -5px" >

                <p style="margin-bottom: 10px">
                    <el-divider content-position="left"><el-text class="mx-1" size="large">已返数据</el-text></el-divider>
                </p>
                <el-row :gutter="20">
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel users suspension" >
                            <div class="small-panel-title">返购池发放金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#44D73AFF" size="20" name="fa fa-cny" />
                                    <span id="users_number">{{data?.back_send_money}}</span>
                                </div>
                                <div class="content-right">
                                    <el-link type="primary"   @click="platform_revenue_action(13)">订单>></el-link>&nbsp;&nbsp;
                                    <el-link type="primary"   @click="user_money_action(15)">用户>></el-link>
                                </div>
                            </div>
                        </div>
                    </el-col>

                    <el-col :sm="12" :lg="6">
                        <div class="small-panel user-reg suspension">
                            <div class="small-panel-title">持币池发放金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#44D73AFF" size="20" name="fa fa-cny" />
                                    <span id="user_reg_number">{{data?.coin_send_money}}</span>
                                </div>

                                <div class="content-right">
                                    <el-link type="primary"   @click="platform_revenue_action(14)">订单>></el-link>&nbsp;&nbsp;
                                    <el-link type="primary"   @click="user_money_action(16)">用户>></el-link>
                                </div>

                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel user-reg suspension">
                            <div class="small-panel-title">股东池发放金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#44D73AFF" size="20" name="fa fa-cny" />
                                    <span id="user_reg_number">{{data?.shareholder_send_money}}</span>
                                </div>

                                <div class="content-right">
                                    <el-link type="primary"   @click="platform_revenue_action(20)">订单>></el-link>&nbsp;&nbsp;
                                    <el-link type="primary"   @click="user_money_action(21)">用户>></el-link>
                                </div>

                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel user-reg suspension">
                            <div class="small-panel-title">十人池发放金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#44D73AFF" size="20" name="fa fa-cny" />
                                    <span id="user_reg_number">{{data?.ten_send_money}}</span>
                                </div>

                                <div class="content-right">
                                    <el-link type="primary"   @click="platform_revenue_action(22)">订单>></el-link>&nbsp;&nbsp;
                                    <el-link type="primary"   @click="user_money_action(23)">用户>></el-link>
                                </div>

                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel user-reg suspension">
                            <div class="small-panel-title">百人池发放金额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#44D73AFF" size="20" name="fa fa-cny" />
                                    <span id="user_reg_number">{{data?.hundred_send_money}}</span>
                                </div>

                                <div class="content-right">
                                    <el-link type="primary"   @click="platform_revenue_action(24)">订单>></el-link>&nbsp;&nbsp;
                                    <el-link type="primary"   @click="user_money_action(25)">用户>></el-link>
                                </div>

                            </div>
                        </div>
                    </el-col>


                </el-row>
            </div>

            <div class="small-panel-box"  style="margin-top: -5px" >
                <p style="margin-bottom: 10px">
                    <el-divider content-position="left"><el-text class="mx-1" size="large">用户收益</el-text></el-divider>
                </p>
                <el-row :gutter="20">
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel users suspension" >
                            <div class="small-panel-title">用户总收益</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#A143DAFF" size="20" name="fa fa-cny" />
                                    <span id="users_number">{{data?.user_total_money}}</span>
                                </div>
                                <div class="content-right"  @click="user_money_action(8)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel user-reg suspension">
                            <div class="small-panel-title">用户余额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#A143DAFF" size="20" name="fa fa-cny" />
                                    <span id="user_reg_number">{{data?.user_money}}</span>
                                </div>
                                <div class="content-right"  @click="user_money_action(9)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                </el-row>
            </div>
            <div class="small-panel-box"  style="margin-top: -5px" >
                <p style="margin-bottom: 10px">
                    <el-divider content-position="left"><el-text class="mx-1" size="large">商家收益</el-text></el-divider>
                </p>
                <el-row :gutter="20">

                    <el-col :sm="12" :lg="6">
                        <div class="small-panel users suspension" >
                            <div class="small-panel-title">商家总收益</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#E02DA6FF" size="20" name="fa fa-cny" />
                                    <span id="users_number">{{data?.shop_total_money}}</span>
                                </div>
                                <div class="content-right"  @click="shop_money_action(10)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel addons suspension" >
                            <div class="small-panel-title">商家余额</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#E02DA6FF" size="20" name="fa fa-cny" />
                                    <span id="addons_number">{{data?.shop_money}}</span>
                                </div>
                                <div class="content-right"  @click="shop_money_action(11)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                </el-row>
            </div>

            <div class="small-panel-box">
                <p style="margin-bottom: 10px">
                    <el-divider content-position="left"><el-text class="mx-1" size="large">持币数</el-text></el-divider>
                </p>
                <el-row :gutter="20">
                    <el-col :sm="12" :lg="6">
                        <div class="small-panel users suspension">
                            <div class="small-panel-title">平台发币数</div>
                            <div class="small-panel-content">
                                <div class="content-left">
                                    <Icon color="#E8076AFF" size="20" name="fa fa-cny" />
                                    <span id="users_number">{{data?.coin_num}}</span>
                                </div>
                                <div class="content-right"  @click="user_action(12)"><el-link type="primary">明细>></el-link></div>
                            </div>
                        </div>
                    </el-col>
                </el-row>
            </div>
        </div>
        <el-dialog
            @close="platform_revenue_show = false"
            width="100%"
            :model-value="platform_revenue_show"
            class="ba-upload-select-dialog"
            :title="platform_revenue_title"
            :append-to-body="true"
            :destroy-on-close="true"
            top="0vh"
        >
            <PlatformRevenue  :platform_revenue_type = platform_revenue_type  :daterange = daterange />
        </el-dialog>



        <el-dialog
            @close="user_money_show = false"
            width="100%"
            :model-value="user_money_show"
            class="ba-upload-select-dialog"
            :title="user_money_title"
            :append-to-body="true"
            :destroy-on-close="true"
            top="0vh"
        >
            <UserMoneyLog  :user_money_type = user_money_type />
        </el-dialog>


        <el-dialog
            @close="shop_money_show = false"
            width="100%"
            :model-value="shop_money_show"
            class="ba-upload-select-dialog"
            :title="shop_money_title"
            :append-to-body="true"
            :destroy-on-close="true"
            top="0vh"
        >
            <ShopMoneyLog  :shop_money_type = shop_money_type />
        </el-dialog>

        <el-dialog
            @close="user_show = false"
            width="100%"
            :model-value="user_show"
            class="ba-upload-select-dialog"
            :title="user_title"
            :append-to-body="true"
            :destroy-on-close="true"
            top="0vh"
        >
            <User  :user_type = user_type />
        </el-dialog>

    </div>


</template>

<script setup lang="ts">
import {onMounted, onUnmounted, reactive, nextTick, onActivated, watch, onBeforeMount, ref} from 'vue'
import headerSvg from '/@/assets/dashboard/header-1.svg'
import coffeeSvg from '/@/assets/dashboard/coffee.svg'
import { CountUp } from 'countup.js'
import * as echarts from 'echarts'
import { useNavTabs } from '/@/stores/navTabs'
import { useTemplateRefsList } from '@vueuse/core'
import { index } from '/@/api/backend/dashboard'
import { useI18n } from 'vue-i18n'
import { Local } from '/@/utils/storage'
import { useAdminInfo } from '/@/stores/adminInfo'
import { WORKING_TIME } from '/@/stores/constant/cacheKey'
import { fullUrl, getGreet } from '/@/utils/common'
import { useEventListener } from '@vueuse/core'
import router from "/@/router";
import createAxios from "/@/utils/axios";

import PlatformRevenue from './dataBoard/platformRevenue.vue'
import UserMoneyLog from './user/moneyLog/index.vue'
import ShopMoneyLog from './shopMoneyLog/index.vue'
import User from './user/user/index.vue'

import { custom_shortcuts } from '/@/utils/custom'

import FormItem from "/@/components/formItem/index.vue";

let workTimer: number

defineOptions({
    name: 'dashboard',
})

const d = new Date()
const { t } = useI18n()
const navTabs = useNavTabs()
const adminInfo = useAdminInfo()
const chartRefs = useTemplateRefsList<HTMLDivElement>()

const state: {
    charts: any[]
    remark: string
    workingTimeFormat: string
    pauseWork: boolean
} = reactive({
    charts: [],
    remark: '',
    workingTimeFormat: '',
    pauseWork: false,
})




const shortcuts = custom_shortcuts()

const daterange = ref()

const data = ref();

const data_board = () => {

    createAxios({
        url: '/admin/data_board/index',
        method: 'get',
        params: {
            date:daterange.value
        }
    }, {
        loading: false
    }, {
        text: '加载中...'
    })
        .then((res) => {

            data.value = res.data.data

        })
        .catch((resx) => {
        })
}

data_board();


// 平台收益明细 和 待返数据明细
const platform_revenue_show = ref(false)
const platform_revenue_title = ref()
const platform_revenue_type = ref(1)
const platform_revenue_action = (type) => {
    if(type == 1){
        platform_revenue_title.value = '平台抽佣明细'
    }else if (type == 2){
        platform_revenue_title.value = '平台发放明细'
    }else if (type == 3){
        platform_revenue_title.value = '平台收益明细'
    }else if (type == 4){
        platform_revenue_title.value = '返购池明细'
    }else if (type == 5){
        platform_revenue_title.value = '持币池明细'
    }else if (type == 6){
        platform_revenue_title.value = '十级池明细'
    }else if (type == 7){
        platform_revenue_title.value = '商家十级池明细'
    }else if (type == 17){
        platform_revenue_title.value = '股东池明细'
    }else if (type == 18){
        platform_revenue_title.value = '十人池明细'
    }else if (type == 19){
        platform_revenue_title.value = '百人池明细'
    }else{
        platform_revenue_title.value = '订单明细'
    }
    platform_revenue_type.value = type;
    platform_revenue_show.value = true;
}


// 用户余额
const user_money_show = ref(false)
const user_money_title = ref()
const user_money_type = ref(8)
const user_money_action = (type) => {
    if(type == 8){
        user_money_title.value = '用户收益明细'
    }else if (type == 9){
        user_money_title.value = '用户余额明细'
    }else if (type == 15){
        user_money_title.value = '用户余额明细'
    }else if (type == 16){
        user_money_title.value = '用户余额明细'
    }
    user_money_type.value = type;
    user_money_show.value = true;
}


// 商家余额
const shop_money_show = ref(false)
const shop_money_title = ref()
const shop_money_type = ref(10)
const shop_money_action = (type) => {
    if(type == 10){
        shop_money_title.value = '商家收益明细'
    }else if (type == 11){
        shop_money_title.value = '商家余额明细'
    }
    shop_money_type.value = type;
    shop_money_show.value = true;
}

// 持币数
const user_show = ref(false)
const user_title = ref()
const user_type = ref(12)
const user_action = (type) => {
    if(type == 12){
        user_title.value = '持币用户'
    }
    user_type.value = type;
    user_show.value = true;
}

</script>

<style scoped lang="scss">
:deep(.el-divider__text){
    position: absolute;
    background-color: #f5f5f5 !important;
    padding: 0 20px;
    font-weight: 500;
    color: var(--el-text-color-primary);
    font-size: 14px;
}

.welcome {
    background: #e1eaf9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 15px 20px !important;
    box-shadow: 0 0 30px 0 rgba(82, 63, 105, 0.05);
    .welcome-img {
        height: 100px;
        margin-right: 10px;
        user-select: none;
    }
    .welcome-title {
        font-size: 1.5rem;
        line-height: 30px;
        color: var(--ba-color-primary-light);
    }
    .welcome-note {
        padding-top: 6px;
        font-size: 15px;
        color: var(--el-text-color-primary);
    }
}
.working {
    height: 130px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    height: 100%;
    position: relative;
    &:hover {
        .working-coffee {
            -webkit-transform: translateY(-4px) scale(1.02);
            -moz-transform: translateY(-4px) scale(1.02);
            -ms-transform: translateY(-4px) scale(1.02);
            -o-transform: translateY(-4px) scale(1.02);
            transform: translateY(-4px) scale(1.02);
            z-index: 999;
        }
    }
    .working-coffee {
        transition: all 0.3s ease;
        width: 80px;
    }
    .working-text {
        display: block;
        width: 100%;
        font-size: 15px;
        text-align: center;
        color: var(--el-text-color-primary);
    }
    .working-opt {
        position: absolute;
        top: -40px;
        right: 10px;
        background-color: rgba($color: #000000, $alpha: 0.3);
        padding: 10px 20px;
        border-radius: 20px;
        color: var(--ba-bg-color-overlay);
        transition: all 0.3s ease;
        cursor: pointer;
        opacity: 0;
        z-index: 999;
        &:active {
            background-color: rgba($color: #000000, $alpha: 0.6);
        }
    }
    &:hover {
        .working-opt {
            opacity: 1;
            top: 0;
        }
        .working-done {
            opacity: 1;
            top: 50px;
        }
    }
}
.small-panel-box {
    margin-top: 20px;
}
.small-panel {
    background-color: #e9edf2;
    border-radius: var(--el-border-radius-base);
    padding: 25px;
    margin-bottom: 20px;
    .small-panel-title {
        color: #92969a;
        font-size: 15px;
    }
    .small-panel-content {
        display: flex;
        align-items: flex-end;
        margin-top: 20px;
        color: #2c3f5d;
        .content-left {
            font-size: 24px;
            .icon {
                margin-right: 10px;
            }
            span {
                display: inline-block;
                font-size: 28px;
            }
        }
        .content-right {
            font-size: 18px;
            margin-left: auto;
        }
        .color-success {
            color: var(--el-color-success);
        }
        .color-warning {
            color: var(--el-color-warning);
        }
        .color-danger {
            color: var(--el-color-danger);
        }
        .color-info {
            color: var(--el-text-color-secondary);
        }
    }
}
.growth-chart {
    margin-bottom: 20px;
}
.user-growth-chart,
.file-growth-chart {
    height: 260px;
}
.new-user-growth {
    height: 300px;
}

.user-source-chart,
.user-surname-chart {
    height: 400px;
}
.new-user-item {
    display: flex;
    align-items: center;
    padding: 20px;
    margin: 10px 15px;
    box-shadow: 0 0 30px 0 rgba(82, 63, 105, 0.05);
    background-color: var(--ba-bg-color-overlay);
    .new-user-avatar {
        height: 48px;
        width: 48px;
        border-radius: 50%;
    }
    .new-user-base {
        margin-left: 10px;
        color: #2c3f5d;
        .new-user-name {
            font-size: 15px;
        }
        .new-user-time {
            font-size: 13px;
        }
    }
    .new-user-arrow {
        margin-left: auto;
    }
}
.new-user-card :deep(.el-card__body) {
    padding: 0;
}

@media screen and (max-width: 425px) {
    .welcome-img {
        display: none;
    }
}
@media screen and (max-width: 1200px) {
    .lg-mb-20 {
        margin-bottom: 20px;
    }
}
html.dark {
    .welcome {
        background-color: var(--ba-bg-color-overlay);
    }
    .small-panel {
        background-color: var(--ba-bg-color-overlay);
        .small-panel-content {
            color: var(--el-text-color-regular);
        }
    }
    .new-user-item {
        .new-user-base {
            color: var(--el-text-color-regular);
        }
    }
}
</style>
